---
title: clsProviderRelationshipCollection
summary: API reference for clsProviderRelationshipCollection.
status: draft
owner: SAIF Doc Gen
last_reviewed: 2026-08-21
library: SAIF.Business.View.Provider
reference_type: embedded
---

# clsProviderRelationshipCollection

`clsProviderRelationshipCollection` loads either the parent or child relationship set for a provider location from the same `PROVIDER_RELATIONSHIP` table, using two different SELECT statements chosen by direction. It also filters the loaded set down to "works for" relationships (`WorksFor`), which is the mechanism `SAIF.Business.Claim.Legal`'s `clsCaseCost` uses to resolve a claimant's employer location.

## Purpose
- Loads relationships in either direction (parent-of or child-of) for a location, each via a dedicated join query (OP-05).
- Filters relationships to only those with relationship code `"WRK"` when reading `WorksFor` ([BR-PREL-001](../../business-rules.md#br-prel-001-works-for-relationships-are-wrk-code)).
- Restricts `WorksFor` to currently active relationships by default, with an opt-out via `ActiveOnly = False` ([BR-PREL-002](../../business-rules.md#br-prel-002-works-for-defaults-to-active-relationships-only)).

## Context
- Namespace: `SAIF.Business.View.Provider`
- Assembly/package: `SAIF.Business.View.Provider` (embedded/project-compiled); also distributed as the NuGet package `SAIF.BOF.Business.View.Provider`.

## Public members
| Member | Signature | Purpose |
| --- | --- | --- |
| `GetChildProviderRelationshipCollection` | `Shared Function GetChildProviderRelationshipCollection(dpi As IDataPortalInfo, providerLocationID As Decimal) As clsProviderRelationshipCollection` | Loads relationships where the given location is the parent (OP-05, SQL-PREL-01). |
| `GetParentProviderRelationshipCollection` | `Shared Function GetParentProviderRelationshipCollection(dpi As IDataPortalInfo, providerLocationID As Decimal) As clsProviderRelationshipCollection` | Loads relationships where the given location is the child (OP-05, SQL-PREL-02). |
| `WorksFor` | `ReadOnly Property WorksFor As clsProviderRelationshipCollection` | Returns relationships with code `"WRK"`, filtered to currently active ones when `ActiveOnly` (default true) ([BR-PREL-001](../../business-rules.md#br-prel-001-works-for-relationships-are-wrk-code), [BR-PREL-002](../../business-rules.md#br-prel-002-works-for-defaults-to-active-relationships-only)). |
| `WorksFor` | `Function WorksFor(asOfDate As Date) As clsProviderRelationshipCollection` | Returns "works for" relationships active as of the given date, treating a missing termination date as `Date.MaxValue` ([BR-PREL-003](../../business-rules.md#br-prel-003-relationship-active-date-determination)). |
| `ActiveOnly` | `Property ActiveOnly As Boolean` | Controls whether `WorksFor` applies the active-date filter; set to `False` to include expired "works for" relationships ([BR-PREL-002](../../business-rules.md#br-prel-002-works-for-defaults-to-active-relationships-only)). |
| `ProviderLocations` | `ReadOnly Property ProviderLocations As clsProviderLocationCollection` | The set of destination locations materialised alongside this relationship collection during load (OP-05). |
| `RelationshipTypes` (enum) | `Public Enum RelationshipTypes` — members `Child`, `Parent` | Identifies which side (`Parent` or `Child`) the collection was sourced from, driving which SELECT (SQL-PREL-01/02) is used and how `DestinationRelationshipType` inverts ([BR-PREL-004](../../business-rules.md#br-prel-004-destination-relationship-type-is-the-opposite-of-the-source)). |
| `Item` | `Default ReadOnly Property Item(index As Integer) As clsProviderRelationship` (from `clsBusinessCollection(Of clsProviderRelationship)`) | Returns the relationship at the given position in the loaded collection. |
| `Count` | `ReadOnly Property Count As Integer` (from `clsBusinessCollection(Of clsProviderRelationship)`) | Number of relationships loaded for the location. |
| `IsValid` | `ReadOnly Property IsValid As Boolean` (overridden from collection base) | Reflects aggregate rule-check state of member relationships; not used to gate any write since none exist. |
| `IsDirty` | `ReadOnly Property IsDirty As Boolean` (overridden from collection base) | Indicates in-memory changes to member relationships; has no effect on persistence ([BR-DATA-001](../../business-rules.md#br-data-001-no-write-operations-are-supported)). |
| `Save` | `Function Save() As clsProviderRelationshipCollection` (overridden from collection base) | Calls `ApplyEdit()`/`MyBase.Save()` but cannot persist since no write SQL exists ([BR-DATA-001](../../business-rules.md#br-data-001-no-write-operations-are-supported)).* |

## Behavioral notes
- OP-05: the criteria stores `SourceRelationshipType` (`Parent` by default); `RetrieveSQL` selects `RetrieveChildRelationshipsSQL` (SQL-PREL-01) when the source is the parent, otherwise `RetrieveParentRelationshipsSQL` (SQL-PREL-02). Both queries join `PROVIDER_LOCATION` to `PROVIDER_RELATIONSHIP` and left-join back to `PROVIDER_LOCATION` for the other end, ordered by business name.
- `AfterRetrieve` builds a `clsProviderLocationCollection` in parallel with the relationship rows, so `ProviderLocations` is populated as a side effect of loading the relationships themselves.

## Constraints and usage notes
- Callers needing "who this location works for" should use `WorksFor`/`WorksFor(date)` rather than iterating the raw collection, to get code and activity filtering applied ([BR-PREL-001](../../business-rules.md#br-prel-001-works-for-relationships-are-wrk-code), [BR-PREL-002](../../business-rules.md#br-prel-002-works-for-defaults-to-active-relationships-only)).
- The collection cannot persist any change to its member relationships ([BR-DATA-001](../../business-rules.md#br-data-001-no-write-operations-are-supported)).

> **Note:** Statements marked with `*` were inferred from code structure, naming
> conventions, or contextual evidence where direct confirmation was not available
> in source artifacts. Statements marked with `**` could not be confirmed; treat
> as unknown until verified.

## Sources
- SAIF.Business.View.Provider/clsProviderRelationshipCollection.vb
